import { Injectable } from '@angular/core';
import {RequestUtil} from "../util/request-util";
import {API} from "../constants/constants";
import {Observable} from "rxjs";
import {MsgResult} from "../models/msg-result";
import {Me} from "../me/me";

@Injectable()
export class PersonalService {

  constructor(
    private  requestUtil :RequestUtil
  ) { }

  /**
   * 获取个人信息
   * @returns {Observable<MsgResult>|any}
   */
  getPersonalInfo():Observable <MsgResult>{
    return this.requestUtil.get(API.getPersonalInfo);
  }

  editPersonalPwd(meInfo :Me):Observable <MsgResult>{
    let params="originalPwd="+meInfo.password+"&newPwd="+meInfo.newPassword+"&accountName="+meInfo.userName;
    return this.requestUtil.post(API.editPersonalPwd,params);
  }
}
